﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using GameUtils.Input;
using GameControls;

namespace ThouShaltNotBrick.Logic.GameStates
{
    internal sealed class IntroGameState : GameStateBase
    {
        #region Constants
        private const string GAME_TITLE = "Thou Shalt Not Brick";
        #endregion

        #region Properties
        private Label mTitleLabel;
        #endregion

        #region Overriden Methods
        protected override void InitializeImpl()
        {
            mClearColor = Color.CornflowerBlue;

            InitializeControls();
        }

        protected override void DestroyImpl()
        {
            DestroyControls();
        }

        protected override void StartImpl(GameStateChangeData pChangeData)
        {
        }

        protected override void StopImpl()
        {
        }

        protected override void ResumeImpl(GameStateChangeData pChangeData)
        {
        }

        protected override void PauseImpl()
        {
        }

        protected override void HandleInputImpl(GameTime pGameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();
            MouseState mouseState = Mouse.GetState();

            if (PollingInput.IsJustPressed(Keys.Escape) ||
                PollingInput.IsJustPressed(Keys.Enter) ||
                PollingInput.IsJustPressed(MouseButton.Left) ||
                PollingInput.IsJustPressed(MouseButton.Right))
            {
                GameStateManager.ChangeState(GameStateType.MainMenu);
            }
        }

        protected override void UpdateImpl(GameTime pGameTime)
        {
        }

        protected override void DrawImpl(GameTime pGameTime)
        {
        }
        #endregion

        #region Methods
        private void InitializeControls()
        {
            DestroyControls();

            Rectangle titleLabelRectangle = new Rectangle(0, 0, mGameManager.GetClientWidth(), mGameManager.GetClientHeight());
            mTitleLabel = new Label(titleLabelRectangle);
            mTitleLabel.SetText(GAME_TITLE, mFontResources.Font28, Color.Black);
            mControls.Add(mTitleLabel);

            Label l1 = new Label(new Rectangle(0, 0, mGameManager.GetClientWidth(), 50));
            l1.SetText("Font20", mFontResources.Font20, Color.Black);
            mControls.Add(l1);

            Label l2 = new Label(new Rectangle(0, 50, mGameManager.GetClientWidth(), 50));
            l2.SetText("Font16", mFontResources.Font16, Color.Black);
            mControls.Add(l2);

            Label l3 = new Label(new Rectangle(0, 100, mGameManager.GetClientWidth(), 50));
            l3.SetText("Font12", mFontResources.Font12, Color.Black);
            mControls.Add(l3);
        }

        private void DestroyControls()
        {
            mControls.Clear();
        }
        #endregion
    }
}